<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ArticleRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
                'title' => 'required|unique:article',
                'description'=>'required',
                'author'=>'required|string',
                'tag_id'=>'required',
                'first_pic' =>'required'
            ];
    }
    public function messages(){
        return [
            'title.required' => '标题必填',
            'title.unique' => '已存在的标题',
            'description.required' => '简介必填',
            'author.required' => '作者必填',
            'tag_id.required' => '标签必填',
            'first_pic.required' => '请上传封面图片',

        ];
    }    
}